package com.ruix.app.ui.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.RequestManager;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.facebook.drawee.view.SimpleDraweeView;
import com.ruix.app.R;
import com.ruix.app.model.Notice;
import com.ruix.app.util.GlideUitl;

import java.util.ArrayList;

import me.iwf.photopicker.utils.AndroidLifecycleUtils;

/**
 * Created by hadexs on 2017/5/3.
 */

public class NoticeDetailListAdapter extends BaseAdapter{
    
    
    private Notice notice;
    private ArrayList<String> album;
    private Context context;
    private LayoutInflater mInflater;

    public NoticeDetailListAdapter(Notice notice, Context context) {
        this.notice = notice;
        this.context = context;
        album = notice.getAlbum();
        mInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }

    @Override
    public int getCount() {
        if (album != null){
          return album.size();
        }
        
        return 0;
    }

    @Override
    public String getItem(int position) {
        return album.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        // R.layout.
        ViewHolder holder;
        if (convertView == null){
            //// TODO: 2017/5/3
            convertView = mInflater.inflate(R.layout.item_notice_ditail_photo, null);
            holder = new ViewHolder();
            holder.draweeView = (ImageView)convertView.findViewById(R.id.sdv_notice_photo);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder)convertView.getTag();
        }
        String url = getItem(position)+ "?x-oss-process=style/thumb_medium";
        GlideUitl.showImageViewCenterCrop(url,holder.draweeView);
        return convertView;
    }
    
    public void relesae(){
        context = null;
        mInflater = null;
    }

    public static class ViewHolder {
        public ImageView draweeView;
    }



}
